/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Random;
import java.util.Scanner;

/**
 * <p>Project: app2022 - Guess
 * <p>Powered by webrx On 2022-01-14 14:07:52
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Guess {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Random rand = new Random();
        int num = rand.nextInt(1,101);
        while(true){
            System.out.print("请输入数字：");
            int temp = 0;
            try{
                temp = sc.nextInt();
            }catch(Exception e){
                if("quit".equals(sc.next())){
                    System.out.println("游戏结束，退出程序。");
                    break;
                }else {
                    System.out.println("输入错误，请输入1-100整数。");
                    //sc.reset();  sc.next()
                    continue;
                }
            }
            if(temp>num){
                System.out.println("太大了");
            }else if(temp<num){
                System.out.println("太小了");
            }else{
                System.out.println("恭喜，猜正确了。");
                break;
            }

        }
    }
}
